<template>
  <div>
    <FastTable
      title="任务"
      :tableHeaderList="columns"
      :tableSearchList="searchList"
      :tableFormList="formList"
      pageNumKey="page"
      pageSizeKey="size"
      :pageStart="0"
      :tableFormWidth="500"
      :listRequest="listRequest"
      :addRequest="addRequest"
      :editRequest="editRequest"
      :detailRequest="detailRequest"
      :deleteRequest="deleteRequest"
      :showLog="true"
      :handleListRequestParams="handleListRequestParams"
      @onWillSearch="onWillSearch"
      @onWillSearchReqeust="onWillSearchReqeust"
      @onDidSearch="onDidSearch"
      @onWillGetList="onWillGetList"
      @onWillGetListRequest="onWillGetListRequest"
      @onGetListSuccess="onGetListSuccess"
      @onGetListError="onGetListError"
      @onWillAdd="onWillAdd"
      @onAddSuccess="onAddSuccess"
      @onAddError="onAddError"
      @onWillEdit="onWillEdit"
      @onEditSuccess="onEditSuccess"
      @onEditError="onEditError"
      @onWillSaveReqeust="onWillSaveReqeust"
      @onWillDelete="onWillDelete"
      @onWillDeleteReqeust="onWillDeleteReqeust"
      @onDeleteSuccess="onDeleteSuccess"
      @onDeleteError="onDeleteError"
      @onFormPrefixClick="onFormPrefixClick"
      @onFormSuffixClick="onFormSuffixClick"
    >
      <template slot="tableCustomForm">
        <div></div>
      </template>
    </FastTable>
  </div>
</template>

<script>
// 导入mixin文件
import mixin from "./mixin";

export default {
  mixins: [mixin],
  name: "TaskPage", // 任务 任务
  data() {
    return {
      /// 表单信息列表
      formList: [
        {
          name: "title", //任务标题
          title: "任务标题",
          type: "text", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "title",
            {
              rules: [{ required: 0, message: "任务标题 为必填项" }],
            },
          ],
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "des", //任务描述
          title: "任务描述",
          type: "text", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "des",
            {
              rules: [{ required: 0, message: "任务描述 为必填项" }],
            },
          ],
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "beginTime", //开始时间
          title: "开始时间",
          type: "date", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "beginTime",
            {
              rules: [{ required: 0, message: "开始时间 为必填项" }],
            },
          ],
          sort: "up",
          align: "left",
          width: 100,
          showTime: true,
        },
        {
          name: "duration", //持续时间(分钟)
          title: "持续时间(分钟)",
          type: "number", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "duration",
            {
              rules: [{ required: 0, message: "持续时间(分钟) 为必填项" }],
            },
          ],
          precision: 0,
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "score", //分数
          title: "分数",
          type: "number", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "score",
            {
              rules: [{ required: 0, message: "分数 为必填项" }],
            },
          ],
          precision: 0,
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "isRepeat", //是否重复 0.否 1.是
          title: "是否重复 0.否 1.是",
          type: "number", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "isRepeat",
            {
              rules: [{ required: 0, message: "是否重复 0.否 1.是 为必填项" }],
            },
          ],
          precision: 0,
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "tag", //标签
          title: "标签",
          type: "text", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "tag",
            {
              rules: [{ required: 0, message: "标签 为必填项" }],
            },
          ],
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "taskCategoryId", //关联任务分类
          title: "关联任务分类",
          type: "select", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "taskCategoryId",
            {
              rules: [{ required: 0, message: "关联任务分类 为必填项" }],
            },
          ],
          options: [],
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "taskLevelId", //关联任务等级
          title: "关联任务等级",
          type: "select", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "taskLevelId",
            {
              rules: [{ required: 0, message: "关联任务等级 为必填项" }],
            },
          ],
          options: [],
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
        {
          name: "learnId", //关联学习
          title: "关联学习",
          type: "select", // text, number, numberRange, select, date, datetime, dateRange
          decorator: [
            "learnId",
            {
              rules: [{ required: 0, message: "关联学习 为必填项" }],
            },
          ],
          options: [],
          sort: "up",
          align: "left",
          width: 100,
          showTime: false,
        },
      ],
    };
  },
  created() {
    this.init();
  },
  methods: {
    callback() {},
    onWillSaveReqeust(params) {
      let user = localStorage.getItem(process.env.VUE_APP_USER_KEY);
      this.log(">>>>> onWillSaveReqeust1", user);
      user = JSON.parse(user);
      this.log(">>>>> onWillSaveReqeust2", user);
      params["userId"] = user.id;
      this.log(">>>>> onWillSaveReqeust3", params);

      return params;
    },
  },
};
</script>

<style lang="less" scoped></style>
